'use client';

import { Button, Result } from "antd";
import Link from "next/link";
import { useSearchParams } from "next/navigation";

const errorMessages = {
  'expired': '邀请链接已过期',
  'max-uses': '邀请链接已达到最大使用次数',
  'invalid': '邀请链接无效',
  'already-joined': '您已经加入了该课程',
  'default': '邀请链接可能已失效或已达到使用上限',
};

export default function JoinErrorPage() {
  const searchParams = useSearchParams();
  const errorType = searchParams.get('type') as keyof typeof errorMessages;
  
  return (
    <div className="min-h-screen flex items-center justify-center">
      <Result
        status="error"
        title="加入课程失败"
        subTitle={errorMessages[errorType] || errorMessages.default}
        extra={[
          <Link href="/courses" key="courses">
            <Button type="primary">浏览课程</Button>
          </Link>,
          <Link href="/" key="home">
            <Button>返回首页</Button>
          </Link>,
        ]}
      />
    </div>
  );
} 